<?php
namespace App\Http\Controllers\Work;

use App\Http\Controllers\Controller;
use App\Common\Utils\JsonResponse;
use Illuminate\Http\Request;

class WorkController extends Controller{

    private $Request;
    private $workService;
    private $logService;

    public function __construct(Request $Request)
    {
        parent::__construct();

        /** @var \App\Services\Work\WorkService $workService */
        $this->workService = app('workService');
        $this->Request = $Request;
        /** @var \App\Services\System\LogService $logService */
        $this->logService = app('logService');
    }

    /**
     * 获取列表
     * @author lxy
     * @datetime 2023-02-28
     */
    public function getWorkList()
    {
        try{
            $result = $this->workService->getWorkList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    //带教情况
    public function getDjqkList()
    {
        try{
            $result = $this->workService->getDjqkList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 添加数据
     * @author lxy
     * @datetime 2022-02-17
     */
    public function addWork()
    {
        try{
            $result = $this->workService->addWork($this->Request->request->all());
            if(!empty($this->Request->all()['id'])){
                $this->logService->log('182','带教情况编辑', "带教情况编辑");
            }else{
                if($this->Request->all()['status'] ==1){
                    $this->logService->log('181','带教情况提交', "带教情况提交");
                }else{
                    $this->logService->log('181','带教情况保存', "带教情况保存");
                }
            }
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 审核
     * @author lxy
     * @datetime 2023-03-07
     */
    public function checkWork()
    {
        try{
            $result = $this->workService->checkWork($this->Request->all());
            if($this->Request->all()['status'] == 'PASS'){
                $this->logService->log('184','带教情况审核通过', "带教情况审核通过");
            }else{
                $this->logService->log('184','带教情况审核驳回', "带教情况审核驳回");
            }
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 删除
     * @author lxy
     * @datetime 2023-03-07
     */
    public function delWork()
    {
        try{
            $result = $this->workService->delWork($this->Request->all());
            $this->logService->log('183','带教情况删除', "带教情况删除");
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 导出
     * @author lxy
     * @datetime 2023-02-24
     */
    public function exportWork()
    {
        try{
            $result = $this->workService->exportWork($this->Request->all());
            $this->logService->log('333','带教情况导出', "带教情况导出");
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }


}


?>
